package com.gugu.procedure.util;

import org.springframework.data.domain.Page;

import java.util.HashMap;
import java.util.Map;

/**
 * @Author: codingliang
 * @Description: 封装分页数据
 * @Date: 2020-06-12 9:49
 * @Version: V1.0
 **/
public class MyPageInfo<T> {

    public Map<String, Object> packagePageInfo(Page<T> page) {
        Map<String, Object> pageInfo = new HashMap<>();
        pageInfo.put("isFirst", page.isFirst());
        pageInfo.put("isLast", page.isLast());
        pageInfo.put("hasNext", page.hasNext());
        pageInfo.put("totalPage", page.getTotalPages());
        pageInfo.put("totalElement", page.getTotalElements());
        pageInfo.put("currentPage", page.getNumber() + 1);
        return pageInfo;
    }
}
